/**
 * schedule 枚举
 * 定义相关的常量值
 */

export enum ScheduleEnum {
  // 状态枚举
  STATUS_ACTIVE = 'active',
  STATUS_INACTIVE = 'inactive',
  STATUS_PENDING = 'pending',
  STATUS_DELETED = 'deleted',

  // 类型枚举
  TYPE_NORMAL = 'normal',
  TYPE_PREMIUM = 'premium',
  TYPE_VIP = 'vip',

  // 级别枚举
  LEVEL_LOW = 1,
  LEVEL_MEDIUM = 2,
  LEVEL_HIGH = 3,
  LEVEL_CRITICAL = 4,
}

/**
 * schedule 字典映射
 */
export const scheduleDict = {
  // 状态映射
  status: {
    [ScheduleEnum.STATUS_ACTIVE]: '激活',
    [ScheduleEnum.STATUS_INACTIVE]: '未激活',
    [ScheduleEnum.STATUS_PENDING]: '待处理',
    [ScheduleEnum.STATUS_DELETED]: '已删除',
  },

  // 类型映射
  type: {
    [ScheduleEnum.TYPE_NORMAL]: '普通',
    [ScheduleEnum.TYPE_PREMIUM]: '高级',
    [ScheduleEnum.TYPE_VIP]: 'VIP',
  },

  // 级别映射
  level: {
    [ScheduleEnum.LEVEL_LOW]: '低',
    [ScheduleEnum.LEVEL_MEDIUM]: '中',
    [ScheduleEnum.LEVEL_HIGH]: '高',
    [ScheduleEnum.LEVEL_CRITICAL]: '紧急',
  },
} as const;

/**
 * schedule 工具类
 */
export class ScheduleEnumUtil {
  /**
   * 获取状态文本
   */
  static getStatusText(status: ScheduleEnum): string {
    return (scheduleDict.status as any)[status] || '未知';
  }

  /**
   * 获取类型文本
   */
  static getTypeText(type: ScheduleEnum): string {
    return (scheduleDict.type as any)[type] || '未知';
  }

  /**
   * 获取级别文本
   */
  static getLevelText(level: ScheduleEnum): string {
    return (scheduleDict.level as any)[level] || '未知';
  }

  /**
   * 获取所有状态选项
   */
  static getStatusOptions(): Array<{ value: string; label: string }> {
    return Object.entries(scheduleDict.status).map(([value, label]) => ({
      value,
      label: label as string,
    }));
  }

  /**
   * 获取所有类型选项
   */
  static getTypeOptions(): Array<{ value: string; label: string }> {
    return Object.entries(scheduleDict.type).map(([value, label]) => ({
      value,
      label: label as string,
    }));
  }

  /**
   * 获取所有级别选项
   */
  static getLevelOptions(): Array<{ value: number; label: string }> {
    return Object.entries(scheduleDict.level).map(([value, label]) => ({
      value: Number(value),
      label: label as string,
    }));
  }

  /**
   * 验证状态值
   */
  static isValidStatus(status: string): boolean {
    return Object.values(ScheduleEnum).includes(status as ScheduleEnum);
  }

  /**
   * 验证类型值
   */
  static isValidType(type: string): boolean {
    return Object.values(ScheduleEnum).includes(type as ScheduleEnum);
  }

  /**
   * 验证级别值
   */
  static isValidLevel(level: number): boolean {
    return Object.values(ScheduleEnum).includes(level as ScheduleEnum);
  }
}

/**
 * schedule 类型定义
 */
export type ScheduleEnumStatus = keyof typeof scheduleDict.status;
export type ScheduleEnumType = keyof typeof scheduleDict.type;
export type ScheduleEnumLevel = keyof typeof scheduleDict.level;
